﻿#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include <string>
using namespace std;
#include "MyArray.hpp"

//1.输出int类型数组；
void printIntArray(MyArray<int>& array)
{
	for (int i = 0; i < array.getSize(); ++i)
	{
		cout << array[i] << endl;
	}
}
class PersonMyArray
{
public:
	PersonMyArray() {}
	PersonMyArray(string name, int age)
	{
		this->m_Name = name;
		this->m_Age = age;
	}

	string m_Name;
	int m_Age;
};
//2.输出PersonMyArray类型数组；
void printPersonMyArray(MyArray<PersonMyArray>& array)
{
	for (int i = 0; i < array.getSize(); ++i)
	{
		cout << "姓名：" << array[i].m_Name << " ，年龄：" << array[i].m_Age << endl;
	}
}

//main308：类模板的应用数组类封装
int main308()
{
	MyArray<int> arr(10);
	for (int i = 0; i < 10; ++i)
	{
		arr.push_Back(i + 100);
	}

	printIntArray(arr);//100,...,109

	PersonMyArray p1("王俊凯", 10);
	PersonMyArray p2("王源", 12);
	PersonMyArray p3("范冰冰", 14);
	PersonMyArray p4("郑爽", 15);

	MyArray<PersonMyArray>arrP(10);
	arrP.push_Back(p1);
	arrP.push_Back(p2);
	arrP.push_Back(p3);
	arrP.push_Back(p4);

	printPersonMyArray(arrP);
	/*姓名：王俊凯 ，年龄：10
	姓名：王源 ，年龄：12
	姓名：范冰冰 ，年龄：14
	姓名：郑爽 ，年龄：15*/

	system("pause");
	return EXIT_SUCCESS;
}